package com.mad.bikepony.model;

public enum DeliveryState {

	WAITING_FOR_PICKUP(0,"waiting for pickup"),
	BEING_DELIVERED(1,"being delivered"),
	DELIVERED(2,"delivered");
	
	private final int state;
	private final String description;
	private DeliveryState(int state,String description) {
		this.state=state;
		this.description=description;
	}
	
	public int toState()
	{
		return this.state;
	}
	public String getDescription()
	{
		return this.description;
	}
	
	public static DeliveryState fromState(int state)
	{
		for(DeliveryState deliveryState: DeliveryState.values())
		{
			if(deliveryState.toState()==state)
				return deliveryState;
		}
		throw new IllegalStateException("no DeliveryState exists for the specified state:"+state);
	}
}
